import java.util.Vector;

public class MyTank extends Tank{
    Bullet bullet = null;

    public boolean isLife() {
        return life;
    }

    public void setLife(boolean life) {
        this.life = life;
    }

    boolean life = true;
    Vector<Bullet> bulletVector = new Vector<>();

    MyTank(int x, int y) {
        super(x, y);
        this.setType(0);
        this.setDirection(0);
    }
    public void up() {
        this.setY(this.getY() - this.getSpeed());
    }
    public void down() {
        this.setY(this.getY() + this.getSpeed());
    }
    public void left() {
        this.setX(this.getX() - this.getSpeed());
    }
    public void right() {
        this.setX(this.getX() + this.getSpeed());
    }
    public void attack() {
        //0向下 1向上 2向左 3向右
        switch(this.getDirection()) {
            case 0:
                bullet = new Bullet(this.getX() + 4,this.getY() + 28,this.getDirection());
                bulletVector.add(bullet);
                break;
            case 1:
                bullet = new Bullet(this.getX() + 4,this.getY() - 22,this.getDirection());
                bulletVector.add(bullet);
                break;
            case 2:
                bullet = new Bullet(this.getX() - 22,this.getY() + 8,this.getDirection());
                bulletVector.add(bullet);
                break;
            case 3:
                bullet = new Bullet(this.getX() + 32,this.getY() + 8,this.getDirection());
                bulletVector.add(bullet);
                break;
        }
        Thread thread = new Thread(bullet);
        thread.start();
//        System.out.println(bullet.getX() + " " + bullet.getY() + " " + bullet.getDirection());
    }

}
